
filename = './dict.txt'  # txt文件和当前脚本在同一目录下，所以不用写具体路径

wfilename = './dict4c.txt'

wf = open(wfilename, 'w')

f = open(filename, 'r')             # 返回一个文件对象
# line = f.readline()             # 调用文件的 readline()方法
lines = f.readlines()  # 读取全部内容

for line in lines:
    line = line.strip()
    print(line)
    print(len(line))
    if len(line) == 4:
        print(line)
        wf.write(line + '\n')
    # line = f.readline()

f.close()
wf.close()
